﻿@{
    ViewBag.Title = "Hợp đồng đã xử lý - Thẻ nhà hàng";
    Layout = "~/Views/Shared/_CpanelLayout.cshtml";
    var status = (List<FOModels.Status.StatusModels>)ViewBag.StatusID;
}
<script type="text/javascript">
    $(document).ready(function () {
        $(".active-tab").removeClass("active-tab");
        $("a[rel=rel-card]").parent().parent().css("display", "block");
        $("a[rel=rel-card]").parent().parent().prev().addClass("active-tab");
        $("a[rel=rel-card]").addClass("active-tab");
    });
</script>
<script type="text/javascript">
    $(document).ready(function () {

        var url = "/RestaurantCard/getfuelcardContractProcessed";
        var rowID = 0;
        var source = {
            datatype: "json",
            datafields: [
                               { name: 'CardApplyID', type: 'int' },
                               { name: 'StatusName', type: 'string' },
                               { name: 'CardImage', type: 'string' },
                               { name: 'CardName', type: 'string' },
                               { name: 'CustomerName', type: 'string' },
                               { name: 'CustomerEmail', type: 'string' },
                               { name: 'CustomerPhone', type: 'string' },
                               { name: 'AppDate', type: 'string' },
            ],
            id: 'CardApplyID',
            url: url
        };
        var imagerenderer = function (row, datafield, value) {
            return '<img style="margin:10px;10px;10px;10px;" height="50" width="100" src="/content/upload/images/' + value + '"/>';
        }
        var imagerenderer_company = function (row, datafield, value) {
            return '<img style="margin:10px;10px;10px;10px;" height="50" width="150" src="/content/upload/images/' + value + '"/>';
        }
        var flagimage = function (row, datafield, value) {
            return '<img style="margin-left: 38px;margin-top: 23px;width: auto;" height="25" width="40" src="/content/images/' + value + '"/>';
        }
        var cellsrenderer = function (row, columnfield, value, defaulthtml, columnproperties) {

            return '<span style="margin: 5px; float: ' + columnproperties.cellsalign + ';">' + value + '</span>';

        }
        var InteresRate = function (row, columnfield, value, defaulthtml, columnproperties) {

            return '<span style="display:block; text-align:center;">' + value + ' %</span>';

        }

        $("#grid_news").jqxGrid({
            width: '100%',
            source: source,
            rowsheight: 70,
            autoheight: true,
            pageable: true,
            sortable: true,
            altrows: true,
            enabletooltips: true,
            selectionmode: 'multiplecellsextended',
            columns: [
            { text: 'ID', datafield: 'CardApplyID', width: 53 },
            { text: 'Trạng thái', datafield: 'StatusName', width: 130, cellsrenderer: cellsrenderer },
            { text: 'Hình ảnh', datafield: 'CardImage', width: 120, height: 70, cellsrenderer: imagerenderer },
            { text: 'Khách hàng', datafield: 'CustomerName', width: 250, cellsrenderer: cellsrenderer },
            { text: 'Email', datafield: 'CustomerEmail', width: 250, cellsrenderer: cellsrenderer },
            { text: 'Số ĐT', datafield: 'CustomerPhone', width: 120, cellsrenderer: cellsrenderer },
            { text: 'Ngày tham gia', datafield: 'AppDate', width: 190, cellsrenderer: cellsrenderer },
            {
                text: 'Chi tiết', datafield: 'Chi tiết', columntype: 'button', width: 70, cellsrenderer: function () {
                    return "Chi tiết";
                }, buttonclick: function (editrow) {
                    var dataRecord = $("#grid_news").jqxGrid('getrowdata', editrow);
                    window.location = "/SavingFuelCard/ContractDetail/" + dataRecord.CardApplyID;
                }
            },

           {
               text: 'Xóa', datafield: 'Xóa', columntype: 'button', width: 70, cellsrenderer: function () {
                   return "Xóa";
               }, buttonclick: function (editrow) {

                   var comfim = confirm("Bạn có thật sự muốn xóa?");
                   if (comfim) {
                       var dataRecord = $("#grid_news").jqxGrid('getrowdata', editrow);
                       $.ajax({
                           type: "POST",
                           url: "/SavingFuelCard/DeleteCardApply",
                           datatype: "json",
                           data: { CardApplyID: dataRecord.CardApplyID },
                           success: function (result) {
                               if (result["Status"] == "OK") {
                                   alert("Xóa thành công");
                                   $("#grid_news").jqxGrid({ source: source });
                               }
                               else {

                                   alert("Xóa thất bại");
                               }
                           }
                       });
                   }


               }
           }
            ]
        });

    });

</script>
<div class="cbread_crumb">
    <ul>
        <li><a href="/Cpanel">Control panel</a></li>
        <li><a href="/Card/ShowCase">Thẻ thanh toán</a></li>
        <li><a href="/RestaurantCard/ShowCase">Thẻ nhà hàng</a></li>
         <li class="lastli"><a href="/RestaurantCard/ContractProcessed">Hợp đồng đã xử lý</a></li>
    </ul>
</div>
<div class="content-module-heading cf">

    <h3 class="fl">Hợp đồng đã xử lý - Thẻ nhà hàng</h3>

</div>
<!-- end content-module-heading -->


<div class="innerLR">
    <div style="margin-top: 10px; margin-bottom: 30px;">
        Trạng thái
    <select name="status" id="status-restaurant">
        @foreach (var s in status)
        {
            if (s.StatusID == 3)
            {
            <option value="@s.StatusID" selected="selected">@s.StatusName</option>
            }
            else
            {
            <option value="@s.StatusID">@s.StatusName</option>   
            }
        }

    </select>
    </div>
    <div id="grid_news"></div>
</div>
